﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Example02.aspx.cs" Inherits="Chapter36.Example02" %>

<!DOCTYPE html>

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>代码清单 36-2 设置 lineCap 属性</title>
    <meta name="author" content="Adam Freeman" />
    <meta name="description" content="A simple example" />
    <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
    <style>
        canvas {
            border: thin solid black;
        }

        body > * {
            float: left;
        }
    </style>
</head>
<body>
    <canvas id="canvas" width="200" height="140">Your browser doesn't support the <code>canvas</code> element.</canvas>
    <script>
        var ctx = document.getElementById('canvas').getContext('2d');

        ctx.strokeStyle = 'red';
        ctx.lineWidth = 2;
        ctx.beginPath();
        ctx.moveTo(0, 50);
        ctx.lineTo(200, 50);
        ctx.stroke();

        ctx.strokeStyle = 'black';
        ctx.lineWidth = 40;

        var xpos = 50;
        var styles = ['butt', 'round', 'square'];
        for (var i = 0; i < styles.length; i++) {
            ctx.beginPath();
            ctx.lineCap = styles[i];
            ctx.moveTo(xpos, 50);
            ctx.lineTo(xpos, 150);
            ctx.stroke();
            xpos += 50;
        }
    </script>
</body>
</html>
